#include "Searcher.hpp"
#include "httplib/httplib.h"

static const std::string base_dir = "./wwwroot";
static const std::string raw_path = "./data/raw_html/raw.txt";
int main()
{
    ns_searcher::Searcher seacher;
    seacher.InitSearcher(raw_path);
    httplib::Server svr;
    svr.set_base_dir(base_dir);
    svr.Get("/s", [&seacher](const httplib::Request &req, httplib::Response &resp)
            { 
                std::string query = req.get_param_value("word");
                std::string json_string;
                seacher.Search(query,&json_string);
                resp.set_content(json_string, "text/plain"); });

    svr.listen("0.0.0.0", 8888);
    return 0;
}
